/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package podologia.beansDB;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Hernan
 */
@Entity
@Table(name = "turno")
@NamedQueries({@NamedQuery(name = "Turno.findByIdTurno", query = "SELECT t FROM Turno t WHERE t.idTurno = :idTurno"), @NamedQuery(name = "Turno.findByHora", query = "SELECT t FROM Turno t WHERE t.hora = :hora"), @NamedQuery(name = "Turno.findByDuracion", query = "SELECT t FROM Turno t WHERE t.duracion = :duracion"), @NamedQuery(name = "Turno.findByAsistencia", query = "SELECT t FROM Turno t WHERE t.asistencia = :asistencia")})
public class Turno implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    @Column(name = "idTurno", nullable = false)
    private Integer idTurno;
    @Column(name = "hora")
    private Long hora;
    @Column(name = "duracion")
    private Long duracion;
    @Column(name = "asistencia")
    private Integer asistencia;
    @JoinColumn(name = "idLugarAte", referencedColumnName = "idLugar")
    @ManyToOne
    private Lugaratencion idLugarAte;
    @JoinColumn(name = "idPaciente", referencedColumnName = "idPaciente")
    @ManyToOne
    private Paciente idPaciente;
    @JoinColumns({@JoinColumn(name = "idPractica", referencedColumnName = "idPractica"), @JoinColumn(name = "legajo", referencedColumnName = "legajo")})
    @ManyToOne
    private Practicaxempleado practicaxempleado;
    @JoinColumn(name = "idAtencion", referencedColumnName = "idAtencion")
    @ManyToOne
    private Atencion idAtencion;

    public Turno() {
    }

    public Turno(Integer idTurno) {
        this.idTurno = idTurno;
    }

    public Integer getIdTurno() {
        return idTurno;
    }

    public void setIdTurno(Integer idTurno) {
        Integer oldIdTurno = this.idTurno;
        this.idTurno = idTurno;
        changeSupport.firePropertyChange("idTurno", oldIdTurno, idTurno);
    }

    public Long getHora() {
        return hora;
    }

    public void setHora(Long hora) {
        Long oldHora = this.hora;
        this.hora = hora;
        changeSupport.firePropertyChange("hora", oldHora, hora);
    }

    public Long getDuracion() {
        return duracion;
    }

    public void setDuracion(Long duracion) {
        Long oldDuracion = this.duracion;
        this.duracion = duracion;
        changeSupport.firePropertyChange("duracion", oldDuracion, duracion);
    }

    public Integer getAsistencia() {
        return asistencia;
    }

    public void setAsistencia(Integer asistencia) {
        Integer oldAsistencia = this.asistencia;
        this.asistencia = asistencia;
        changeSupport.firePropertyChange("asistencia", oldAsistencia, asistencia);
    }

    public Lugaratencion getIdLugarAte() {
        return idLugarAte;
    }

    public void setIdLugarAte(Lugaratencion idLugarAte) {
        Lugaratencion oldIdLugarAte = this.idLugarAte;
        this.idLugarAte = idLugarAte;
        changeSupport.firePropertyChange("idLugarAte", oldIdLugarAte, idLugarAte);
    }

    public Paciente getIdPaciente() {
        return idPaciente;
    }

    public void setIdPaciente(Paciente idPaciente) {
        Paciente oldIdPaciente = this.idPaciente;
        this.idPaciente = idPaciente;
        changeSupport.firePropertyChange("idPaciente", oldIdPaciente, idPaciente);
    }

    public Practicaxempleado getPracticaxempleado() {
        return practicaxempleado;
    }

    public void setPracticaxempleado(Practicaxempleado practicaxempleado) {
        Practicaxempleado oldPracticaxempleado = this.practicaxempleado;
        this.practicaxempleado = practicaxempleado;
        changeSupport.firePropertyChange("practicaxempleado", oldPracticaxempleado, practicaxempleado);
    }

    public Atencion getIdAtencion() {
        return idAtencion;
    }

    public void setIdAtencion(Atencion idAtencion) {
        Atencion oldIdAtencion = this.idAtencion;
        this.idAtencion = idAtencion;
        changeSupport.firePropertyChange("idAtencion", oldIdAtencion, idAtencion);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTurno != null ? idTurno.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Turno)) {
            return false;
        }
        Turno other = (Turno) object;
        if ((this.idTurno == null && other.idTurno != null) || (this.idTurno != null && !this.idTurno.equals(other.idTurno))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "podologia.beansDB.Turno[idTurno=" + idTurno + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
